import requests
import re

headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36'
}
# 百度搜索的接口
# url = r'http://www.baidu.com/s'
# data = {'wd': '郑州天气'}
# resp = requests.get(url, params=data, headers=headers)
# resp.encoding = 'utf-8'
# patt = r'<title>(.*?)</title>'
# title = re.findall(patt, resp.text)
# print(title)

# #手机号归属地查询
headers= {'Content-Type':'application/x-www-form-urlencoded'}
url=r'http://apis.juhe.cn/mobile/get'
data= {'phone':'13526295970','key':'5378aee730bed2c13275a3653caa81cd','dtype':'string'}
resp=requests.get(url,params=data,headers=headers)
print(resp.json())
print(resp.json()['result']['province'])
# 天气get
# url=r'http://apis.juhe.cn/simpleWeather/query'
# data= {'city':'郑州','key':'4d73e3244ca47fcd365d269408cf08bf'}
# resp=requests.get(url,params=data,headers=headers)
# print(resp.text)
# # 天气post
# url=r'http://apis.juhe.cn/simpleWeather/query'
# data= {'city':'郑州','key':'4d73e3244ca47fcd365d269408cf08bf'}
# resp=requests.post(url,params=data,headers=headers)
# print(type(resp.json()))
